package acmCoder;

import java.util.Scanner;

public class MBitIs1 {

	public static void main(String[] args) {
		Scanner  scanner = new Scanner(System.in);
		int leftNumber, rightNumber, mBit1;
		while (scanner.hasNext()) {
			leftNumber = scanner.nextInt();
			rightNumber = scanner.nextInt();
			mBit1 = scanner.nextInt();
			calculate(leftNumber, rightNumber, mBit1);
		}
		scanner.close();
	}
	
	public static void calculate(int leftNumber, int rightNumber, int mBit1){
		int possibleCount = 0;
		for (int i = leftNumber; i <= rightNumber; i++) {
			if(getBit1Count(i) == mBit1){
				possibleCount ++;
			}
		}
		if(possibleCount == 0){
			System.out.println(-1);
		}else {
			System.out.println(possibleCount);
		}
	}
	public static int getBit1Count(long x){
		if(x == 0 ){
			return 0;
		}
		int count = 0;
		while(x != 0){
			count += ( x & 1) == 0 ? 0 : 1;
			x >>= 1;
		}
		return count;
	}
}
